﻿/*
 * Rappelz: Endless Odyssey - The first free open source Rappelz server emulator
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rappelz.GameServer.Network.AuthClient
{
    #region Enums
    /// <summary>
    /// Enum for packets the game server can send to the login server
    /// </summary>
    enum ServerOutPackets : ushort
    {
        ServerLogin = 20001,
        ClientLogin = 20010,
        ClientLogout = 20012,
        ClientKickFail = 20014,
        SecurityNoCheckResult = 40001,
    }

    /// <summary>
    /// Enum for packets the login server can send to the game server
    /// </summary>
    enum ServerInPackets : ushort
    {
        ServerLoginResult = 20002,
        ClientLoginResult = 20011,
        KickClient = 20013,
        ItemPurchased = 30000,
        ItemSupplied = 30001,
        SecurityNoCheck = 40000,
    }
    #endregion

    public class ClientLoginResultPacketAG : PacketIn
    {
        public String szAccount;
        public int nAccountId;
        public ushort result;
        public byte nPCBangUser;
        public int nEventCode;
        public int nAge;
        public uint nContinuousPlayTime;
        public uint nContinuousLogoutTime;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="buf">Buffer containing packet data to read from</param>
        /// <param name="start">Starting index into buf</param>
        /// <param name="size">Number of bytes to read from buf</param>
        public ClientLoginResultPacketAG(byte[] buf, int start, int size)
            : base(buf, start, size)
        {
            szAccount = ReadString(61);
            nAccountId = ReadInt32();
            result = ReadUInt16();
            nPCBangUser = (byte)ReadByte();
            nEventCode = ReadInt32();
            nAge = ReadInt32();
            nContinuousPlayTime = ReadUInt32();
            nContinuousLogoutTime = ReadUInt32();
        }
    }

    public class KickClientPacketAG : PacketIn
    {
        public String szAccount;
        public byte kick_type;

        public enum KickType : byte
        {
            AnotherLogin = 0,
            Duplicate = 1,
            BillingExpired = 2,
            GameAddiction = 3,
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="buf">Buffer containing packet data to read from</param>
        /// <param name="start">Starting index into buf</param>
        /// <param name="size">Number of bytes to read from buf</param>
        public KickClientPacketAG(byte[] buf, int start, int size)
            : base(buf, start, size)
        {
            szAccount = ReadString(61);
            kick_type = (byte)ReadByte();
        }
    }

}
